//
//  MeatOrderLocationCell.m
//  PigMarket
//
//  Created by 张敬 on 2019/7/26.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "MeatOrderLocationCell.h"

@interface MeatOrderLocationCell ()

/**
 默认
 */
@property (nonatomic, strong) UILabel *defaultLab;


/**
 城市
 */
@property (nonatomic, strong) UILabel *cityLab;


/**
 创业总部基地B区12号楼1208室
 */
@property (nonatomic, strong) UILabel *locationLab;


/**
 傅小小/电话
 */
@property (nonatomic, strong) UILabel *nameLab;


/**
 arrowBtn
 */
@property (nonatomic, strong) UIButton *arrowBtn;




@end


@implementation MeatOrderLocationCell

#pragma mark - lifecycle methods

- (void)setupUI{
    
    _type = MeatOrderLocationCellType_None;
    
    [self addSubview:self.defaultLab];
    [self addSubview:self.cityLab];
    [self addSubview:self.locationLab];
    [self addSubview:self.nameLab];
    [self addSubview:self.arrowBtn];
    
}

- (void)setupLayout{
    
    _defaultLab.text = @"默认";
    _cityLab.text = @"天津市 武清区";
    _nameLab.text = @"傅小小 182****7820";
    
    CGFloat width = KScreenWidth - 30;
    CGFloat height = 90;
    
    {
        _defaultLab.size = CGSizeMake(50, 16);
        _defaultLab.mj_x = _defaultLab.mj_y = 15;
    }
    
    
    {
        _cityLab.mj_x = _defaultLab.right + 5;
        _cityLab.mj_y = _defaultLab.mj_y;
        _cityLab.height = _defaultLab.height;
        _cityLab.width = width - _cityLab.left - 40;
    }
    
    
    {
        _locationLab.mj_x = 15;
        _locationLab.height = 22;
        _locationLab.mj_y = _cityLab.bottom +4;
        _locationLab.width = width - 55;
    }
    
    {
        _nameLab.mj_x = 15;
        _nameLab.mj_y = _locationLab.bottom + 4;
        _nameLab.width = _locationLab.width;
        _nameLab.height = 17;
    }
    
    {
        _arrowBtn.size = CGSizeMake(40, 40);
        _arrowBtn.mj_y = (height - _arrowBtn.height)/2.0;
        _arrowBtn.mj_x = width - _arrowBtn.width;
    }
    
    if (self.type == MeatOrderLocationCellType_None)
    {
        _defaultLab.hidden = YES;
        _nameLab.hidden = YES;
        _cityLab.hidden = YES;
        
        NSMutableAttributedString *aims =  [@"  选择送货地址" createAttributingByIcon:@"meat_buy_location" downIndexImage:nil textColor:UIColorFromRGB(0x333333) font:mFont(17)];
        _locationLab.attributedText = aims;
        
    }else{
        
        _defaultLab.hidden = NO;
        _nameLab.hidden = NO;
        _cityLab.hidden = NO;
        
        _locationLab.text = @"创业总部基地B区12号楼1208室";
        _locationLab.textColor = UIColorFromRGB(0x6262626);
        
    }
}

#pragma mark - public methods

#pragma mark - setter methods

- (void)setType:(MeatOrderLocationCellType)type{
    
    _type = type;
    [self setupLayout];
}


#pragma mark - getter methods

- (UILabel *)defaultLab{
    
    if (!_defaultLab) {
        _defaultLab = [UILabel makeLabelWithText:@"" textColor:KWhiteColor font:mFont(11) textAliment:1];
        [self addShadowAndCircleCorner:_defaultLab.layer corner:8];
        _defaultLab.backgroundColor = UIColorFromRGB(0xFF8A00);
    }
    return _defaultLab;
}


- (UILabel *)cityLab{
    
    if (!_cityLab) {
        _cityLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0x666666) font:mFont(12) textAliment:0];
    }
    return _cityLab;
}


- (UILabel *)locationLab{
    
    if (!_locationLab) {
        _locationLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0x6262626) font:mFont(16) textAliment:0];
    }
    return _locationLab;
}


- (UILabel *)nameLab{
    
    if (!_nameLab) {
        _nameLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0x808080) font:mFont(12) textAliment:0];
    }
    return _nameLab;
}


- (UIButton *)arrowBtn{
    
    if (!_arrowBtn) {
        _arrowBtn = [UIButton makeButtonWithImageName:@"meat_order_input"];
        _arrowBtn.contentMode = UIControlContentHorizontalAlignmentRight;
        
    }
    return _arrowBtn;
}


@end
